package com.gxy.learn.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RefreshScope
@RestController
public class TestController {

    /**
     * 读取nacos中的配置
     */
    @Value("${user.name}")
    private String userName;

    /**
     * 读取nacos中的配置
     */
    @Value("${user.learn}")
    private String userLearn;

    @Value("${user.hobby}")
    private String userHobby;

    @GetMapping("/config/test")
    public String hello() {
        String result = String.format("userName = %s,userHobby = %s,userLearn = %s", userName, userHobby, userLearn);
        log.info(result);
        return result;
    }
}
